package com.jiazhong.mybatis.m4;

import com.jiazhong.commons.bean.Emp;
import com.jiazhong.mybatis.m4.mapper.EmpMapper;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;
import java.util.Arrays;
import java.util.List;

public class App {

    private static void a() {
        InputStream in = App.class.getClassLoader().getResourceAsStream("config.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(in);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        EmpMapper mapper = sqlSession.getMapper(EmpMapper.class);
        List<Emp> list = mapper.find1("asdhjs");
        sqlSession.close();
    }

    /*
    根据用户选择职位、姓名模糊、工资范围
     */
    private static void b() {
        InputStream in = App.class.getClassLoader().getResourceAsStream("config.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(in);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        EmpMapper mapper = sqlSession.getMapper(EmpMapper.class);
        Emp emp = new Emp();
        emp.setMaxSal(8989.0);
        emp.setJob("hdjshdj");
        emp.setEname("%李%");
        mapper.find2(emp);
        sqlSession.close();
    }

    private static void c() {
        InputStream in = App.class.getClassLoader().getResourceAsStream("config.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(in);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        EmpMapper mapper = sqlSession.getMapper(EmpMapper.class);
        mapper.find3(8);
        sqlSession.close();
    }
    private static void d() {
        InputStream in = App.class.getClassLoader().getResourceAsStream("config.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(in);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        EmpMapper mapper = sqlSession.getMapper(EmpMapper.class);
        Emp emp = new Emp();
        emp.setMaxSal(8989.0);
       // emp.setJob("hdjshdj");
        emp.setEname("shdushd");
        mapper.find4(emp);
        sqlSession.close();
    }
    private static void e() {
        InputStream in = App.class.getClassLoader().getResourceAsStream("config.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(in);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        EmpMapper mapper = sqlSession.getMapper(EmpMapper.class);
        List<String> jobs = Arrays.asList("程序员","网页设计");
       // List<String> jobs = null;
        mapper.find5(jobs);
        sqlSession.close();
    }
    private static void f() {
        InputStream in = App.class.getClassLoader().getResourceAsStream("config.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(in);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        EmpMapper mapper = sqlSession.getMapper(EmpMapper.class);
        Emp emp = new Emp();
        emp.setEname("ab");
        mapper.find6(emp);
        sqlSession.close();
    }
    public static void main(String[] args) {
        f();
    }
}